import { makeAutoObservable } from 'mobx'
// import { outLoginApi } from '../api'
import { Dialog } from 'antd-mobile'
import { stores } from '@/stores'
import { getNowDate, getNowPeriod, getNowWeek } from '@/utils/formatterDate'
// import * as Storage from '@/storage'

class Store {
    public trainerInfo: Record<string, any> = {}
    constructor() {
        makeAutoObservable(this)
        this.initUserData()
    }

    initUserData = async () => {
        this.trainerInfo = {
            ...stores.userStore.getUserInfo,
            name: stores.userStore.roleName,
            welcomeWord: getNowPeriod() === 'AM' ? '早上好' : '下午好',
            dateNow: getNowDate(),
            week: getNowWeek(),
        }
    }

    outLogin = async () => {
        Dialog.confirm({
            title: '退出登录',
            content: '是否退出当前账号',
            onConfirm: async () => {
                stores.userStore.logout()
            },
        })
    }
}

export default Store
